package ua.com.minus1.lookbattle.menu;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import ua.com.minus1.lookbattle.R;

/**
 * Created with IntelliJ IDEA.
 * User: Igorek
 * Date: 10/26/12
 * Time: 9:16 PM
 * To change this template use File | Settings | File Templates.
 */
public class ClicksActionView extends FrameLayout {
    private TextView mTextView;
    private String mClicks;

    public ClicksActionView(Context context) {
        this(context, null);
    }

    public ClicksActionView(Context context, AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.action_view_clicks, this);

        mTextView = (TextView) findViewById(R.id.action_view_clicks_text);
        setClicks(0);

        setOnClickListener(new OnClickListener() {
              public void onClick(View view) {
                toggle();
            }
        });
    }

    public void setClicks(int c) {
        mClicks = String.valueOf(c);
        mTextView.setText(mClicks);
    }

    public void toggle() {
        if(mTextView.getText().equals("CLICKS"))
            mTextView.setText(mClicks);
        else
            mTextView.setText("CLICKS");
    }
}
